#include "Person.h"
#include "Date.h"
#include "Master.h"
#include <QDebug>
#include "DataManager/SqlEditDialog.h"

Person::Person()
{
    Master *master=Master::getMaster();
    connect(master->getDate(),SIGNAL(dateSig_newDay(Date*)),this,SLOT(goWork(Date*)));
}

Person::Person(const Person &person):QGraphicsObject(),Sprite(person)
{

}

bool Person::Init(City *city)
{
    this->m_spriteType=SpriteType_Person;
    this->m_belongCity=city;
    this->data.strength=5;
    this->data.intelligence=5;
    return true;
}

void Person::loadDataFromModel()
{
    DataObj *obj=Master::getMaster()->getDataManager()->getPersonData(this->data.index);
    PersonData *data=dynamic_cast<PersonData *>(obj);
    this->data.name=data->name;
}

QRectF Person::boundingRect() const
{
    qreal adjust = 0.5;
    return QRectF(-18 - adjust, -22 - adjust,
                  36 + adjust, 60 + adjust);
}

void Person::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
}

QString Person::getName() const
{
    return this->data.name;
}

void Person::setName(QString &name)
{
    this->data.name=name;
}

double Person::getStrenth() const
{
    return this->data.strength;
}

double Person::getIntelligence() const
{
    return this->data.intelligence;
}

void Person::goWork(Date *date)
{
    qDebug()<<"go to Work at "<<date->toString();
}
